// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   JRockitLegacyInstantiator.java

package org.springframework.objenesis.instantiator.jrockit;

import java.lang.reflect.Method;
import org.springframework.objenesis.ObjenesisException;
import org.springframework.objenesis.instantiator.ObjectInstantiator;

public class JRockitLegacyInstantiator
	implements ObjectInstantiator
{

	private static Method safeAllocObjectMethod = null;
	private final Class type;

	private static void initialize()
	{
		if (safeAllocObjectMethod == null)
			try
			{
				Class memSystem = Class.forName("jrockit.vm.MemSystem");
				safeAllocObjectMethod = memSystem.getDeclaredMethod("safeAllocObject", new Class[] {
					java/lang/Class
				});
				safeAllocObjectMethod.setAccessible(true);
			}
			catch (RuntimeException e)
			{
				throw new ObjenesisException(e);
			}
			catch (ClassNotFoundException e)
			{
				throw new ObjenesisException(e);
			}
			catch (NoSuchMethodException e)
			{
				throw new ObjenesisException(e);
			}
	}

	public JRockitLegacyInstantiator(Class type)
	{
		initialize();
		this.type = type;
	}

	public Object newInstance()
	{
		return type.cast(safeAllocObjectMethod.invoke(null, new Object[] {
			type
		}));
		Exception e;
		e;
		throw new ObjenesisException(e);
	}

}
